<template lang="pug">
  DataTablePage(
    pid="parentId"
    cid="id"
    mainColumn="name"
    longColumn="name"
    resource="/dxbase/rbac/org"
    title="组织架构管理"
    label="组织"
    labelName="name"
    :isTree="true"
    :toolbar="toolbar"
    :operation="operation"
    :operationWidth=150
    :tableFullList="tableFullList"
    :tableInitList="tableInitList"
    :filterFullList="filterFullList"
    :filterInitList="filterInitList"
    :createList="createList"
    :updateList="updateList"
    :createFormValues="createFormValues"
    :columns="columns")
</template>

<script>
import DataTablePage from '@/containers/DataTablePage'
import { toolbarCreate } from '@/containers/DataTablePage/toolbar'
import { operationCreate, operationUpdate, operationDelete } from '@/containers/DataTablePage/operation'
import { checkActions } from '@/utils/auth'
import config from '../config/organization'

export default {
  name: 'SystemOrganization',
  components: {
    DataTablePage
  },
  data () {
    const hasUpdate = checkActions('/system/#/organization/update')
    const hasCreate = checkActions('/system/#/organization/create')
    const hasDelete = checkActions('/system/#/organization/delete')
    return {
      ...config,
      toolbar: [{
        ...toolbarCreate,
        isShow () {
          return checkActions('/system/#/organization/create')
        }
      }],
      operation: [{
        ...operationCreate,
        isShow () {
          return hasCreate
        }
      }, {
        ...operationUpdate,
        isShow () {
          return hasUpdate
        }
      }, {
        ...operationDelete,
        isShow () {
          return hasDelete
        }
      }],
      tableInitList: ['name', 'orgTypeName', 'enabled', 'remark'],
      tableFullList: ['name', 'orgTypeName', 'enabled', 'remark'],
      filterInitList: ['name', 'orgTypeId', 'enabled'],
      filterFullList: ['name', 'orgTypeId', 'enabled'],
      createList: ['name', 'orgTypeId', 'enabled', 'parentId', 'remark'],
      updateList: ['name', 'orgTypeId', 'enabled', 'parentId', 'remark'],
      createFormValues: {
        parentId: '',
        name: '',
        orgTypeId: '',
        enabled: 1,
        remark: ''
      }
    }
  }
}
</script>
